using System;
using System.Data;
using System.Xml;

using OR.Reuse.Persistence;

using Derived = OR.Lazarus.Library.CPP.Rules;

namespace OR.Lazarus.Library.CPP.Rules.Lazarus
{
	/// <summary>
	/// Defines a set of files that should always be included in the results.
	/// </summary>
   public class IncludeDetail : EntityBase
   {
		protected System.String mId;
		protected string mFile;
		protected string mDescription;

		public IncludeDetail()
		{
	
		}
	
		/// <summary>
		/// 
		/// </summary>
		public System.String Id
		{
			get
			{
				return ( mId );
			}
			set
			{
				mId = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string File
		{
			get
			{
				return ( mFile );
			}
			set
			{
				mFile = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string Description
		{
			get
			{
				return ( mDescription );
			}
			set
			{
				mDescription = value;
			}
		}

		public override void LoadXml( XmlElement pSource )
		{
			// Scalar Values
			mId = DataUtility.GetString( pSource, "id" );
			mFile = DataUtility.GetString( pSource, "file" );
			XmlElement vDescription = ( XmlElement )pSource.SelectSingleNode( "lzr:description", PersistenceConfig.Namespaces );
			
			if ( vDescription != null )
			{
				mDescription = vDescription.InnerText;
			}
			
		}
		
		public override XmlElement SaveXml( XmlDocument p_docContext )
		{
			XmlElement vNewElement	= p_docContext.CreateElement( "lzr", "include", "http://schemas.icitadel.com/Lazarus/CPP/Rules.xsd" );

			// Scalar Values
			if ( !String.IsNullOrEmpty( mId ) )
			{
				vNewElement.SetAttribute( "id", mId );
			}
					
			if ( !String.IsNullOrEmpty( mFile ) )
			{
				vNewElement.SetAttribute( "file", mFile );
			}
					
			if ( !String.IsNullOrEmpty( mDescription ) )
			{
				XmlElement	vDescription = p_docContext.CreateElement( "lzr", "description", "http://schemas.icitadel.com/Lazarus/CPP/Rules.xsd" );
				vDescription.InnerText = mDescription;
				vNewElement.AppendChild( vDescription );
			}
					

			return ( vNewElement );
		}

		public virtual object Clone()
		{
			Derived.IncludeDetail v_oReturn = new Derived.IncludeDetail();
			
			v_oReturn.Id = mId;
			v_oReturn.File = mFile;
			v_oReturn.Description = mDescription;
			
			// FK Values

			// Collections
			
			return ( v_oReturn );
		}

		public virtual Derived.IncludeDetail CloneTyped()
		{
			return ( ( Derived.IncludeDetail )this.Clone() );
		}
   }
}
   